<?php

namespace app\controllers;

use app\models\tableModel\BlockModel;
use app\models\tableModel\NewsCategoryModel;
use app\models\tableModel\SettingModel;
use app\models\tableModel\UserModel;
use app\service\RequestService;
use app\service\tool\UtilsService;
use Codeception\Module\DumbHelper;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
use yii\helpers\StringHelper;

/**
 * [CRUD]操作控制器
 */
class TestController extends BaseController
{


    public function actionIndex()
    {

        $model = NewsCategoryModel::loadModel()->ails('cate')->loadWhere([
            'id' => 233
        ])->getPaginate(1, 2);
        var_dump(
            $model->total,
            $model->list
        );die;
    }


    // 用户登录
    public function actionLogin()
    {

        return false;
        if (!\Yii::$app->user->isGuest) return $this->jsonSuccess('成功', [
            '已经登录，无需在登录',
        ]);

        // 登录所需数据
        $data = [
            'LoginForm' => [
                'username'   => 'editor001',
                'password'   => 'admin233',
                'rememberMe' => $this->post('rememberMe')
            ]
        ];

        // 实例化登录类
        $model = new LoginForm();
        // 执行登录
        if (!$model->load($data) || !$model->login()) {

            $err = UtilsService::getModelError($model->errors);
            return $this->jsonFail($err['msg'], 400, [
                'error_hint' => $err
            ]);
        }

        // 提示
        return $this->jsonSuccess('成功', \Yii::$app->getUser()->getIdentity());
    }

    public function actionLogout()
    {
        return false;
        \Yii::$app->user->logout();
    }
}
